package com.itheima.mapper;

import com.github.pagehelper.Page;
import com.itheima.pojo.Setmeal;
import com.itheima.pojo.SetmealCount;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SetmealMapper {

    /**
     * 分页查询
     * @param queryString
     * @return
     */
    Page<Setmeal> pageQuery(String queryString);

    /**
     * 添加套餐
     * @param setmeal
     */
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into t_setmeal (name, code, help_code, sex, age, price, remark, attention, img) " +
            "VALUES (#{name},#{code},#{helpCode},#{sex},#{age},#{price},#{remark},#{attention},#{img})")
    void insert(Setmeal setmeal);

    /**
     * 根据套餐id删除套餐
     * @param id
     */
    @Delete("delete from t_setmeal where id = #{id}")
    void deleteById(Integer id);

    /**
     * 根据条件查询套餐
     * @param setmeal
     * @return
     */
    List<Setmeal> select(Setmeal setmeal);

    /**
     * 更新套餐
     * @param setmeal
     */
    void update(Setmeal setmeal);

    /**
     * 查询套餐名称和数量
     * @return
     */
    List<SetmealCount> selectSetmealNameAndCount(Integer top);

    /**
     * 查询所有的套餐
     * @return
     */
    @Select("select id, name, code, help_code, sex, age, price, remark, attention, img from t_setmeal")
    List<Setmeal> selectAll();

    /**
     * 根据套餐id查询套餐
     * @param id
     * @return
     */
    Setmeal selectById(Integer id);
}
